Release 10.1A: OpenEdge Development:
Programming Interfaces
Initializing and uninitializing MEMPTR variables
Typically when you initialize a
MEMPTRvariable, you use theSET-SIZEstatement to allocate a region of memory for a specified size and associate it with the variable. You can also use a shared library routine to allocate the memory for aMEMPTRvariable by passing the variable appropriately as aRETURNparameter to the routine. Then, to completeMEMPTRinitialization, you should use theSET-SIZEstatement so that Progress knows how big the memory area is.You must know the exact size of data returned by the shared library routine to initialize the
Caution: If you specify a size that is too small, Progress prevents you from accessing parts of the returned structure that lie outside the specified region. However, if you specify a size that is too large (or do not complete initialization at all), you might cause a memory violation by inappropriately accessing memory outside the area of the structure. This can result in loss of data. To determine the size of structures allocated and returned by shared library routines, see the documentation for the routine you are calling.MEMPTRvariable properly with theSET-SIZEstatement. If you use an incorrect value, you might not be able to access the data as you expect. Note also that if you do not complete initialization of a shared library pre-initializedMEMPTRvariable using theSET-SIZEstatement, Progress does not perform any bounds checking when you read or modify contents of the structure.Freeing memory associated with a MEMPTR variable
The region of memory associated with a
MEMPTRvariable remains allocated until it is freed. In some cases, the shared library routine frees the memory; in other cases, the calling procedure must free the memory using theSET-SIZEstatement to set its size to zero (0). Progress cannot free the memory for you. It is up to you to ensure that the memory is freed, depending on the functionality of each shared library routine you use.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |